const Parse = require('parse/node');

const {appId,masterKey,serverURL}=require('../config/parse_server_config.js');
Parse.initialize(appId, masterKey,masterKey);
Parse.serverURL = serverURL;

const axios=require("axios");
const ParseHelper = require("../helpers/parse");

async function create_parse_database(className){
    try{
        const url=`${serverURL}/schemas/${className}`;
        const response = await axios({
            method:"POST",
            url,
            headers: {
                'Content-Type': 'application/json',
                'X-Parse-Application-Id': appId,
                'X-Parse-Master-Key': masterKey,
                //"InstallationId":"b1c9f0db-dbc4-4fcf-922f-bffb5dc00fa6",
            },
        });
        return response.data;
    }catch(e){
        console.error(e)
    }
}


async function create_parse_databases(){
    try{
        //const classNames=['v5_view_setting'];
        const classNames=["AutoBorrow_Kinds","AutoBorrow_Goods","AutoBorrow_Counts",
            "AutoBorrow_BorrowList","AutoBorrow_Records",'AutoBorrow_WhiteList',
            'AutoBorrow_BorrowTime',"AutoBorrow_KouDaiRecord","AutoBorrow_TakenRecords",
            "AutoBorrow_Cabinets","AutoBorrow_Category","AutoBorrow_CabinetLogs",
            "AutoBorrow_CabinetGrids"];
        for (const className of classNames) {
            await create_parse_database(className);

        }
    }catch (e) {
        console.error(e)
    }
}


create_parse_databases();